package com.zwh.config.database;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * 多数据源配置类
 * @author jiangxianliang
 * @since 2021/5/12
 */
@Configuration
public class DataSourceConfig {
	/**
	 * PSI 库连接配置前缀 (与 yml 中的连接信息前缀一致 , 下同)
	 */
	private static final String DATASOURCE_MASTER_PREFIX = "spring.datasource.druid.master";
	/**
	 * PSI 库连接Bean名字
	 */
	public static final String DATASOURCE_MASTER_BEAN_NAME = "master";

	/**
	 * B2B 库中间库连接配置前缀
	 */
	private static final String PACSV55_DB_DATASOURCE_PREFIX = "spring.datasource.druid.pacsdbv55";
	/**
	 * B2B 库中间库连接Bean名字
	 */
	public static final String PACSV55_DB_DATASOURCE_BEAN_NAME = "pacsv55db";

	/**
	 * HIS 库中间库连接配置前缀
	 */
	private static final String HIS_DB_DATASOURCE_PREFIX = "spring.datasource.druid.his";
	/**
	 * HIS 库中间库连接Bean名字
	 */
	public static final String HIS_DB_DATASOURCE_BEAN_NAME = "his";

	/**
	 * HIS 库中间库连接配置前缀
	 */
	private static final String HIS_EMT_DB_DATASOURCE_PREFIX = "spring.datasource.druid.hisemt";

	/**
	 * HIS EMT 库中间库连接Bean名字
	 */
	public static final String HIS_EMT_DB_DATASOURCE_BEAN_NAME = "hisemt";

	/**
	 * EMR 库中间库连接配置前缀
	 */
	private static final String EMR_DB_DATASOURCE_PREFIX = "spring.datasource.druid.emr";

	/**
	 * EMR 库中间库连接Bean名字
	 */
	public static final String EMR_DB_DATASOURCE_BEAN_NAME = "emr";

	@Primary
	@Bean(name = DATASOURCE_MASTER_BEAN_NAME)
	@ConfigurationProperties(prefix = DATASOURCE_MASTER_PREFIX)
	public DruidDataSource masterDataSource() {
		return new DruidDataSource();
	}

//	@Bean(name = PACSV55_DB_DATASOURCE_BEAN_NAME)
//	@ConfigurationProperties(prefix = PACSV55_DB_DATASOURCE_PREFIX)
//	public DruidDataSource pacsv55dbDataSource() {
//		return new DruidDataSource();
//	}
//
//	@Bean(name = HIS_DB_DATASOURCE_BEAN_NAME)
//	@ConfigurationProperties(prefix = HIS_DB_DATASOURCE_PREFIX)
//	public DruidDataSource hisdbDataSource() {
//		return new DruidDataSource();
//	}
//
//	@Bean(name = HIS_EMT_DB_DATASOURCE_BEAN_NAME)
//	@ConfigurationProperties(prefix = HIS_EMT_DB_DATASOURCE_PREFIX)
//	public DruidDataSource hisemtDbDataSource() {
//		return new DruidDataSource();
//	}
//
//	@Bean(name = EMR_DB_DATASOURCE_BEAN_NAME)
//	@ConfigurationProperties(prefix = EMR_DB_DATASOURCE_PREFIX)
//	public DruidDataSource emrDbDataSource() {
//		return new DruidDataSource();
//	}
}
